require("racket")
require("rosetta")

backend(autocad)

function rectangleLine(p1, p2, p3, p4) {
  return join(spline(list(p1, p2)),
              spline(list(p2, p3)),
              spline(list(p3, p4)),
              spline(list(p4, p1)));
}

function crater(c, p1, p2, p3, p4, r) {
  return
    loft(
      rectangleLine(p1, p2, p3, p4),
      moveZ(0.1 * r, circle(c, r)),
      moveZ(0.8 * r, circle(c, 0.7 * r)),
      circle(c, 0.4 * r));
}

crater(addZC(midcoord(u0, uxy), 2), u0, ux, uxy, uy, 2)